<div class="main-content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <div class="card-header border-bottom">
                        <h4 class="card-title">资源</h4>
                        <button type="button" class="btn btn-common mb-2" data-toggle="modal" data-target=".modal-create-resource">添加</button>
                    </div>
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-bordered mb-0">
                                <thead>
                                <tr>
                                    <th>#</th>
                                    <th>公众号</th>
                                    <th>录入时间</th>
                                    <th>状态</th>
                                    <th>备注</th>
                                </tr>
                                </thead>
                                <tbody>
                                <?php
                                $num = count($resources);
                                for ($l=0; $l<$num; $l++){  ?>
                                    <tr>
                                        <th scope="row"><?php echo $l+1; ?></th>
                                        <td><?php echo $resources[$l]["sub_name"]; ?></td>
                                        <td><?php echo $resources[$l]["collect_time"]; ?></td>
                                        <td>
                                            <?php
                                            switch ($resources[$l]["status"]){
                                                case 0:
                                                    ?><span class="badge badge-success">正常</span><?php
                                                    break;
                                                case 1:
                                                    ?><span class="badge badge-danger">异常</span><?php
                                                    break;
                                                default:
                                                    ?><span class="badge badge-danger">异常</span><?php
                                            }
                                            ?>
                                        </td>
                                        <td>
                                            <?php echo $resources[$l]["note"]; ?>
                                        </td>
                                    </tr>
                                <?php }  ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<div class="modal fade modal-create-resource" tabindex="-1" role="dialog"
     aria-labelledby="添加资源" aria-hidden="true" style="display: none;">
    <form action="/<?php echo site_url("resources/create"); ?>" method="post">
        <div class="modal-dialog modal-dialog-centered">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title">添加资源</h5>
                    <button type="button" class="close" data-dismiss="modal"
                            aria-hidden="true">×</button>
                </div>
                <div class="modal-body">
                    <div class="form-group">
                        <label>公众号名称</label>
                        <input type="text" name="sub_name" class="form-control form-control-lg" required>
                    </div>
                    <div class="form-group">
                        <label>token</label>
                        <input type="text" name="token" class="form-control" required>
                    </div>
                    <div class="form-group">
                        <label>cookie</label>
                        <textarea class="form-control" name="cookie" rows="4" required></textarea>
                    </div>
                    <div class="form-group">
                        <label>备注</label>
                        <input type="text" name="note" class="form-control">
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-common">添加</button>
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
                </div>
            </div>
        </div>
    </form>
</div>